<template>
  <!--登录页面-->
  <div class="login-main" v-loading="wxLoginLoading" element-loading-background="rgba(255, 255, 255, 0.4)">
    <div class="login-top">
      <div class="login-top-content">
        <div class="login-top-left">
          <img src="../../assets/images/Denglu/u4.png" />
          <span class="login-top-title">宏运集团管理系统</span>
        </div>
      </div>
    </div>
    <div class="login-warp" :style="{height:minHeight + 'px'}">
      <div class="login-content">
        <div class="login-left">
          <div class="slogan-box" :style="{marginTop:(minHeight-470)/2 + 'px'}">
            <img src="../../assets/images/Denglu/f4.png" style="display:block;">
          </div>
        </div>
        <div class="login-right" v-loading="loading" element-loading-background="rgba(255, 255, 255, 0.4)" :style="{marginTop:(minHeight-470)/2 + 'px'}">
          <!-- <span @click="checkERcode" v-if="side">
              <img src="../../assets/images/Denglu/s.png" style="display:block;width:40px"> </span>
            <span @click="checkERcode" v-else>
              <img src="../../assets/images/Denglu/t.png" style="width:40px">
            </span> -->
          <div class="portal-login-sys" v-show="side">
            <p>系统登录</p>
            <div class="login-title" v-bind:class="{on:active}">{{message}}</div>
            <div class="login-form">
              <div class="login-name">
                <img src="../../assets/images/Denglu/f1.jpg" style="width:40px;vertical-align:middle;">
                <input class="jc-input-hover " type="text" placeholder="请输入账号" v-model.trim="loginData.name" maxlength="20">
              </div>
              <div class="login-name">
                <img src="../../assets/images/Denglu/f2.jpg" style="width:40px;vertical-align:middle;">
                <input class="jc-input-hover" type="password" placeholder="请输入密码" v-model.trim="loginData.password" maxlength="20">
              </div>
              <button class="jc-button-hover login-button" @click="Sign">登录</button>
            </div>
          </div>
        </div>
      </div>
    </div>
    <p class="login-bottom">版权所有 宏运集团 </p>
  </div>
</template>
<script>
import axios from 'axios'
export default {
  name: '',
  data() {
    return {
      loginData: {
        name: '',
        password: ''
      },
      side: true,
      active: false,
      message: '请输入正确的密码',
      loading: false,
      // centerDialogVisible: false,
      wxLoginLoading: false,
      flag: true
    }
  },
  computed: {
    minHeight() {
      return document.documentElement.scrollHeight - 185
    }
  },
  created() {
    let that = this
    document.onkeydown = function(e) {
      e = window.event || e
      if (
        that.$route.path == '/' &&
        (e.code == 'Enter' || e.code == 'NumpadEnter' || e.code == 'enter')
      ) {
        //验证在登录界面和按得键是回车键enter
        that.Sign() //登录函数
      }
    }
    localStorage.clear()
  },
  mounted() {},
  methods: {
    Sign() {
      if (
        this.loginData.name.length !== 0 &&
        this.loginData.password.length >= 6
      ) {
        this.loginPush()
      } else {
        if (this.loginData.name.length === 0) {
          this.$message.error('请输入账号')
        } else if (this.loginData.password.length < 6) {
          this.$message.error('请输入有效的密码')
        }
      }
    },
    loginPush() {
      var obj = {
        name: this.loginData.name,
        pass: this.loginData.password
      };
      var objs = JSON.stringify(obj);
      axios("/apis/ComApi.asmx/Login?jsondata=" + objs).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        var list = JSON.parse(datas.string.__text);
        if (list.Tip == "登录成功!") {
          this.$message.success("登录成功!");
          localStorage.setItem("message", JSON.stringify(list));
          localStorage.setItem("rankList", JSON.stringify(list.lstpower));
          this.$router.push({
            path: list.lstpower[0].tworank[0].url,//"/PersonalCenterHmPg",
            query:{index:list.lstpower[0].onerank[0].menuId}// { index: 1 }
          });
        } else {
          this.$message.error(list.Tip);
        }
      });
    }
  }
}
</script>
<style scoped>
.login-info {
  overflow-x: auto;
  margin-bottom: 10px;
}
.login-info p {
  line-height: 30px;
}
.jc-input-hover:focus {
  box-shadow: -2px -2px 5px #999;
}
.jc-button-hover {
  transition: all 0.3s;
}
.jc-button-hover:hover {
  box-shadow: 2px 2px 5px rgb(8, 86, 146);
}
.icon-yonghu-tianchong {
  background: url('../../assets/images/Denglu/f1.jpg') no-repeat;
}
.login-main {
  width: 100%;
  height: 100%;
  overflow: auto;
}
.login-input-name {
  float: right;
}
.login-top {
  height: 60px;
  width: 100%;
}
.login-top-content {
  margin: 0 auto;
  width: 1200px;
  max-width: 1200px;
  height: 100%;
}
.login-top-left {
  /* float:left; */
  text-align: center;
  width: 80%;
  height: 100%;
  position: relative;
}
.login-top-left img {
  width: 70px;
  position: absolute;
  left: 400px;
  bottom: -30px;
}
.login-top-left .login-top-title {
  padding-left: 15px;
  letter-spacing: 2px;
  font-size: 30px;
  display: inline-block;
  position: absolute;
  font-weight: bold;
  /* left: 220px; */
  bottom: -14px;
}
.login-warp {
  background: url('./../../assets/images/Denglu/u2.png') no-repeat;
  background-size: 100% 100%;
  min-height: 470px;
}
.login-content::after {
  clear: both;
  content: '';
  display: table;
}
.login-content {
  margin: 40px auto 0;
  height: 100%;
  width: 1200px;
  max-width: 1200px;
  overflow: hidden;
}
.login-left {
  float: left;
  width: 54%;
}
/*.login-left > img:nth-child(1) {
  display: block;
  width: 20%;
}*/
.slogan-oa span,
.slogan-ob span {
  display: inline-block;
  width: 150px;
  text-align: center;
}
.slogan-oa span {
  font-size: 26px;
  color: rgba(8, 86, 146, 0.5);
  letter-spacing: 5px;
}
.slogan-ob span {
  margin-top: 10px;
  font-size: 17px;
  color: #333;
  letter-spacing: 3px;
}
.slogan-box {
  /* display: none; */
  margin: 15% 0% 35% 40%;
  color: white;
  background: rgba(255, 255, 255, 0.4) none repeat scroll 0 0;
  float: right;
  position: relative;
  text-align: center;
  height: 470px;
}
.login-left > p {
  color: black;
  font-size: 14px;
  text-align: center;
}
.login-right {
  margin-right: 191px;
  color: white;
  background: rgba(255, 255, 255, 0.4) none repeat scroll 0 0;
  float: right;
  position: relative;
  text-align: center;
  width: 30%;
  height: 470px;
}
.login-right > span {
  cursor: pointer;
  position: absolute;
  right: 0;
  top: 0;
}
.portal-login-sys {
  margin: 50px auto 80px;
  width: 250px;
}
.portal-login-sys > p {
  border-bottom: 1px solid white;
  color: white;
  font-size: 22px;
  padding-bottom: 15px;
  letter-spacing: 2px;
}
.login-title {
  background: rgba(8, 86, 146, 0.5) none repeat scroll 0 0;
  color: rgba(8, 86, 146, 0.5);
  margin: 10px 0;
  padding: 10px 15px;
  text-align: left;
  opacity: 0;
  font-size: 12px;
}
.login-button {
  border-radius: 5px;
}
.login-name {
  margin-bottom: 20px;
  overflow: hidden;
  border-radius: 5px;
}
.login-icon-box {
  display: block;
  height: 100%;
  text-align: center;
  line-height: 32px;
  font-size: 14px;
  float: left;
  width: 40px;
  background: rgb(8, 86, 146);
}
.login-name > input {
  border: medium none;
  float: right;
  height: 32px;
  padding-left: 7px;
  width: 203px;
}
.login-name.login-check > input {
  width: 95px;
}
img.check-val {
  float: right;
  height: 32px;
  width: 80px;
  padding: 0 5px 0 0;
  background: #fff;
}
.login-form > button {
  background: rgb(8, 86, 146);
  border: medium none;
  /* border-radius: 5px; */
  color: white;
  font-size: 18px;
  line-height: 38px;
  margin-top: 40px;
  width: 100%;
  cursor: pointer;
}
.login-status {
  font-size: 12px;
}
.login-status > div {
  float: left;
}
.login-status > span {
  float: right;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}
.login-status input {
  margin-right: 5px;
  vertical-align: middle;
}
.login-sn > img {
  margin: 30px auto;
  width: 72.5%;
}
label {
  cursor: pointer;
}
.login-title.on {
  opacity: 1;
}
.login-bottom {
  width: 100%;
  height: 60px;
  line-height: 60px;
  text-align: center;
  font-size: 12px;
}
</style>
